import React from 'react';
import ReactDOM from 'react-dom';

// 添加客户端history路由
import { Provider } from 'react-redux';
import { BrowserRouter, Switch } from 'react-router-dom';
import { renderRoutes } from 'react-router-config';

import configureStore from './redux/configureStore';
import routes from './routes';
// import './index.css';
// import * as serviceWorker from '../serviceWorker';

const initState = window.__INITIAL_STATE__;
console.log('initState client',initState);
const store = configureStore(initState); 
const App = () => (
  <div>
    <Provider store={store}> 
      <BrowserRouter>
        <Switch>
          {renderRoutes(routes)}
        </Switch>
      </BrowserRouter>
    </Provider>     
  </div>
);

ReactDOM.hydrate(<App />, document.getElementById('root'));